package com.gjy.console.jline;

import org.jline.reader.Candidate;
import org.jline.reader.Completer;
import org.jline.reader.LineReader;
import org.jline.reader.ParsedLine;

import java.util.Arrays;
import java.util.List;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-09-04 19:54:11
 */
public class MyCompleter implements Completer {

    private final List<String> commands = Arrays.asList("delete", "download", "exit", "help", "list", "search", "upload", "version");

    @Override
    public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
        String word = line.word();
        commands.stream()
                .filter(c -> c.startsWith(word))
                .forEach(c -> candidates.add(new Candidate(c)));
    }

}
